package org.xx.armory.swing;

import org.xx.armory.swing.controllers.DialogUIModelController;
import org.xx.armory.swing.controllers.FrameUIModelController;
import org.xx.armory.swing.controllers.InternalFrameUIModelController;
import org.xx.armory.swing.controllers.MDIFrameUIModelController;
import org.xx.armory.swing.builders.StandardUIModelController;
import org.xx.armory.swing.components.DialogPane;
import org.xx.armory.swing.components.InternalFramePane;

import javax.swing.*;

import static org.xx.armory.commons.Validators.notNull;

/**
 * 用户界面控制器工具类。
 */
public final class UIControllers {
    public static final StandardUIController GLOBAL = createGlobalUIController();
    public static final StandardUIController STANDARD = createStandardUIController();

    /**
     * 禁止实例化工具类。
     */
    private UIControllers() {
    }

    private static StandardUIController createStandardUIController() {
        return new StandardUIModelController("standard/ui");
    }

    private static StandardUIController createGlobalUIController() {
        return new StandardUIModelController("global");
    }

    public static UIController createFrameUIController(
            JFrame frame
    ) {
        notNull(frame, "frame");

        return new FrameUIModelController(frame);
    }

    public static UIController createDialogUIController(
            DialogPane dialog
    ) {
        notNull(dialog, "dialog");

        return new DialogUIModelController(dialog);
    }

    public static MDIFrameUIController createMDIFrameUIController(
            JFrame frame
    ) {
        notNull(frame, "frame");

        return new MDIFrameUIModelController(frame);
    }

    public static InternalFrameUIController createInternalFrameUIController(
            InternalFramePane frame
    ) {
        notNull(frame, "frame");

        return new InternalFrameUIModelController(frame);
    }
}
